//
//  TSConfig.swift
//  TSLiveWallpaper
//
//  Created by 100Years on 2024/12/20.
//

public let TSConfigShared = TSConfig.shared
open class TSConfig: NSObject {
    public static var shared = TSConfig()
    
    public static let appLanguage: String = {
        let systemLanguages = UserDefaults.standard.value(forKey: "AppleLanguages")
        var currentLanguage: String?
        if let arr = systemLanguages as? [String] {
            currentLanguage = arr.first
        }
        else if let str = systemLanguages as? String {
            currentLanguage = str
        }
        return currentLanguage ?? ""
    }()
    
    public static let appLanguageShort: String? = {
        let currentLanguage = Bundle.main.preferredLocalizations.first
        if let str = currentLanguage?.components(separatedBy: "-").first,
           str.count >= 2 {
            return str
        }
        return nil
    }()
    
    public static let isLanguageZh: Bool = {
        if appLanguage.lowercased().hasPrefix("zh") {
            return true
        }
        return false
    }()
    
    static let isLanguageJa: Bool = {
        if appLanguage.lowercased().hasPrefix("ja") {
            return true
        }
        return false
    }()
    
    static var languageSuffix: String {
        if appLanguage.lowercased().hasPrefix("zh") {
            return "-zh"
        }
        return ""
    }
    
    public static var isChinaRegion: Bool {
//#if DEBUG
//        return true
//#endif
        let localeId = Locale.current.identifier
        return localeId.contains("_CN")
    }
    
    static let ligntSolidDefaultColor:UIColor = "#FAC0D6".uiColor
    
    static func isArabicSupported() -> Bool {
        // 获取项目支持的所有本地化语言
        // 检查是否包含阿拉伯语（"ar"）
        return Bundle.main.localizations.contains("ar")
    }

}
